<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport"
          content="width=device-width,user-scalable=no, initial-scale=1">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>历次服务评价</title>
    <%- include('./_global/baseLibs') %>
    <link rel="stylesheet"  href="/static/css/mycontract.css" />
</head>
<style>
    div.content-box{
        line-height: 2rem;
    }
    div.pj-box{
        height:2rem;
    }
    div.pj-box >span{
        float: left;
        width: 6rem;
    }
    div.star-box{
        float: left;
        display: inline-block;
        position: relative;
        vertical-align: middle;
        line-height: 2rem;
        width: 10rem;
        height:2rem;
    }
    div.star-box>ul{
        height:100%;
        width:100%;

    }
    div.star-box>ul>li{
        height:100%;
        width: 20%;
        float: left;
    }
    div.star-box>ul>li>a{
        display: block;
        height: 80%;
        width:80%;

    }
    .star{
        background: url("/static/images/red-star.png") no-repeat;
        background-size: cover;
    }
    .star-gray{
        background: url("/static/images/star.png") no-repeat;
        background-size: cover;
    }
</style>

<body>
<section class="page-wrap doctor-service">
    <header class="header-box grey fixed">
        <div class="header-content">
            <div class="left-tool">
                <a class="back" href="javascript:void(0);"><i class="iconfont icon-back"></i></a>
            </div>
            <div class="title">服务评价</div>
        </div>
    </header>
    <div class="doctor-list-box">
        <ul id="lcfwContainer">

        </ul>
    </div>
</section>
</body>
<!-- 历次服务评价 -->
<script type="text/html" id="lcfwDiv">
    <li>
        <div class="content-box">
            <span>服务时间：<span name="wcfwsj" style="display: inline"></span><span class="text-right">服务医生：<span
                            name="fwysxmys" style="display: inline"></span></span></span>
            <span name="fwnr">服务内容：</span>
            <span name="fwpj">服务评价：</span>
            <div class="pj-box">
                <span>服务及时性：</span>
                <div class="star-box">
                    <ul class="fwjsx">
                    </ul>
                </div>
            </div>
            <div class="pj-box">
                <span>服务专业性：</span>
                <div class="star-box">
                    <ul class="fwzyx">
                    </ul>
                </div>
            </div>
            <div class="pj-box">
                <span>服务态度：</span>
                <div class="star-box">
                    <ul class="fwtd">
                    </ul>
                </div>
            </div>
        </div>
        <a class="pj-btn" href="javascript:void(0);">去评价</a>
    </li>
</script>
<script type="text/html" id="starLi">
    <li>
        <a class="star"></a>
    </li>
</script>
<script type="text/html" id="grayStarLi">
    <li>
        <a class="star-gray"></a>
    </li>
</script>
<script type="text/javascript">


    var page_lcfwpj = (function($, page_lcfwpj) {
        function initView() {
            /**去评价*/
            $("#lcfwContainer").on("click", ".pj-btn", function () {
                var fwxx = $(this).data("fwxx");
                var fwmc = StoreCache.getCache("QYFW_DPJFWXX_FWMC");
                fwxx.fwmc=fwmc;
                var sjfwsj = fwxx.sjfwsj;
                sjfwsj = sjfwsj.substr(0,10);
                fwxx.sjfwsj = sjfwsj;
                StoreCache.setCache("QYFW_DPJFWXX", fwxx);
                $.QuickUrlUtils.redirectJSBridge({url:"/html/common/signService/fwpj.html",title:"服务评价"});
            })
        }

        function initData() {
            var fwxx = StoreCache.getCache("QYFW_FWXX") || {};
            var param = {};
            param.fwid = fwxx.fwid;
            param.qyxxid = fwxx.qyxxid;
            param.fwbid = fwxx.fwbid;
            param.pageSize=10;
            param.pageNumber=1;
            /**查询历次服务评价*/
            $.QuickRemote.AjaxJson({funcName:"/api/gzd/qyfw/queryYwcfwByPageToJkcs", callback:function (result) {
                page_lcfwpj.createLcfwlb(result.rows);
            },params: param});
        }
        /**创建历次服务列表*/
        function createLcfwlb(ary) {
            var container = $("#lcfwContainer");
            container.empty();
            $(ary).each(function (index, item) {
                var lcfw = $($("#lcfwDiv").html());
                page_lcfwpj.setBaseInfo(lcfw, item);
                page_lcfwpj.setStarInfo(lcfw, item);
                if (!StringUtils.isEmpty(item.fwjsx)) {
                    lcfw.find(".pj-btn").remove();
                } else {
                    lcfw.find(".pj-btn").data("fwxx", item);
                }
                container.append(lcfw);
            });
        }
        /**  设置基本信息  */
        function setBaseInfo(lcfw, item) {
            var sjfwsj = item.sjfwsj;
            sjfwsj = sjfwsj.substr(0,10);
            var fwxx = StoreCache.getCache("QYFW_FWXX") || {};
            $(lcfw).find("span[name=wcfwsj]").append(sjfwsj);
            $(lcfw).find("span[name=fwysxmys]").append(fwxx.fwysxmys);
            $(lcfw).find("span[name=fwnr]").append(item.fwnr);
        }

        /**  设置星级评价、意见反馈 */
        function setStarInfo(lcfw, item) {
            page_lcfwpj.addStar(lcfw, item["fwjsx"], lcfw.find(".fwjsx"));
            page_lcfwpj.addStar(lcfw, item["fwzyx"], lcfw.find(".fwzyx"));
            page_lcfwpj.addStar(lcfw, item["fwtd"],  lcfw.find(".fwtd"));
            $(lcfw).find("[name=fwpj]").append(item.jyfk || "暂无评价");
        }

        /**添加服务评价星级*/
        function addStar(lcfw, xj, lx) {
            if (StringUtils.isEmpty(xj) || xj == "") {
                xj = 0;
            } else {
                xj = parseInt(xj);
            }
            for (var i = 1; i <= 5; i++) {
                var star = "";
                if (i <= xj) {
                    star = $($("#starLi").html());
                } else {
                    star = $($("#grayStarLi").html());
                }
                lx.append(star);
            }
        }

        var cfg_def = {
            initView: initView,
            initData: initData,
            createLcfwlb: createLcfwlb,
            setBaseInfo: setBaseInfo,
            setStarInfo: setStarInfo,
            addStar: addStar,
        }

        page_lcfwpj.init = function(cfg){
            $.extend(page_lcfwpj, cfg_def, cfg);
            page_lcfwpj.initView();
            page_lcfwpj.initData();

        }

        return page_lcfwpj;
    })(jQuery, {});
    


</script>

</html>
